package jmetest.awt.swingui.dnd;

import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;

import javax.swing.Icon;

/**
 * Transferable for text drag and drop / for debugging
 *
 * @author galun
 * @version $Id: TransferableImage.java,v 1.2 2007/08/14 13:43:37 rherlitz Exp $
 */
public class TransferableImage implements Transferable {
    final static public DataFlavor IMAGE_FLAVOR = new DataFlavor( TransferableImage.class, "Image" );
    static DataFlavor flavors[] = {IMAGE_FLAVOR};
    private Icon icon;

    public TransferableImage( Icon icon ) {
        this.icon = icon;
    }

    public DataFlavor[] getTransferDataFlavors() {
        return flavors;
    }

    public boolean isDataFlavorSupported( DataFlavor flavor ) {
        return flavor.equals( IMAGE_FLAVOR );
    }

    public Object getTransferData( DataFlavor flavor ) throws UnsupportedFlavorException, IOException {
        return icon;
    }

	public Icon getIcon() {
		return icon;
	}

}
